### texreg method for polr objects
extract.krls.quartile.pooled <- function(model.file, include.r2 = TRUE,
                                         include.nobs = TRUE, ...) {

  foo <- readRDS(model.file)
  r2 <- median(unlist(lapply(foo, function(x){x$R2})))
  
  coef <- apply(do.call("rbind", lapply(foo, function(x){x$derivatives})),2,median)
  low25 <- apply(do.call("rbind", lapply(foo, function(x){x$derivatives})),2,quantile,1/4)
  high75 <- apply(do.call("rbind", lapply(foo, function(x){x$derivatives})),2,quantile,3/4)
  
  names <- names(coef)
  
  n <- dim(foo[[1]]$derivatives)[1]
  
  gof <- numeric()
  gof.names <- character()
  gof.decimal <- logical()
  
  if (include.r2 == TRUE) {
    gof <- c(gof, r2)
    gof.names <- c(gof.names, "R2")
    gof.decimal <- c(gof.decimal, TRUE)
  }

  if (include.nobs == TRUE) {
    gof <- c(gof, n)
    gof.names <- c(gof.names, "Number of Observations")
    gof.decimal <- c(gof.decimal, FALSE)
  }
  
  tr <- createTexreg(
    coef.names = names,
    coef = coef,
    ci.low = low25,
    ci.up = high75,
    gof.names = gof.names,
    gof = gof,
    gof.decimal = gof.decimal
  )
  return(tr)
}
